import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-06-02
 * Time: 23:17
 */
public class TestDemo {

    public static void insertSort(int[] array){
        for(int i =1;i<array.length;++i){
             int tmp = array[i];
             int j = i-1;
             for(;j>=0;--j){
                 if(tmp>array[j]){
                     break;
                 }else {
                     array[j+1] = array[j];
                 }
             }
             array[j+1]=tmp;
        }
    }

    public static void main(String[] args) {
        int[] array = {8,9,6,4,5,3,1,7,2,0};
        insertSort(array);
        System.out.println(Arrays.toString(array));
    }

}
